import express from 'express';
let app = express();

// 引入swagger
import setSwagger from './swagger';
setSwagger(app);

// 引入post解析中间件
import bodyParser from 'body-parser';
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

// 引入跨域中间件
import cors from 'cors';
app.use(cors());

// 引入路由
import setRouter from './router';
setRouter(app);

// 引入日志
import logger from './logger';

// 启用 http 及 https 服务
import { PORT, NODE_ENV } from './config';
import http from 'http';
http.createServer(app).listen(PORT, () => {
  logger.info(`🚀 服务启动成功! 监听端口号 ${PORT}, Node服务环境 ${NODE_ENV}`);
});
